package com.travel.controller;

import com.qianfeng.util.ResultMsg;
import com.travel.entity.TbHome;
import com.travel.entity.TbHotel;
import com.travel.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/adminHome")
public class AdminHomeController {

    @Autowired
    HomeService homeService;

    /**
     * 按照酒店id查找所有房间
     * */
    @GetMapping("/getAllByHotelId")
    public ResultMsg getAllByHotelId(Integer hotelId){
        return homeService.getAllByHotelId(hotelId);
    }

    /**
     * 按照房间id查找
     * */
    @GetMapping("/getOneByHotelId")
    public ResultMsg getOneByHotelId(int hotelId){
        return homeService.getOneByHotelId(hotelId);
    }

    /**
     * 按照酒店id查找所有房间(分页)
     * */
    @GetMapping("/getAllByHotelIdPage")
    public ResultMsg getAllByHotelIdPage(Integer hotelId, Integer current,Integer size){
        return homeService.getAllByHotelIdPage(hotelId,current,size);
    }

    /**
     * 按照酒店id添加新房间
     * */
    @PostMapping("/adminInsertOne")
    public ResultMsg insertOne(@RequestBody TbHome home){
        return homeService.insertOne(home);
    }

    /**
     * 按照房间id修改房间信息
     * */
    @PostMapping("/adminUpdateOne")
    public ResultMsg updateOne(@RequestBody TbHome home){
        return homeService.updateOne(home);
    }

    /**
     * 按照房间id删除房间
     * */
    @GetMapping("/adminDeleteOne")
    public ResultMsg deleteOne(Integer homeId){
        return homeService.deleteOne(homeId);
    }



}
